/**
 * 结构体排序
 */
#include <bits/stdc++.h>
using namespace std;

struct _t{
    string name;
    array<int, 5> score;
};

int N;
vector<_t> A;
vector<pair<string, double>> B;

void proc(int s, int e, int full, double fac){
    for(int i=s;i<e;++i){
        int mmax = 0;
        for(auto & t : A){
            if(mmax < t.score[i]) mmax = t.score[i];
        }
        for(int j=0;j<N;++j){
            B[j].second += fac * full * A[j].score[i] / mmax;
        }
    }
    return;
}

void proc(){
    B.assign(N, {});
    for(int i=0;i<N;++i) B[i].first = A[i].name, B[i].second = 0;

    proc(0, 1, 600, 0.25);
    proc(1, 3, 300, 0.25);
    proc(3, 5, 300, 0.5);
    sort(B.begin(), B.end(), [](pair<string, double> a, pair<string, double> b){
        auto tmp = a.second - b.second;
        if(fabs(tmp) > 1E-5) return tmp > 0;
        return a.first < b.first;
    });
    for(const auto & t :B) cout << t.first << " " << fixed << setprecision(5) << t.second << endl;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif // ONLINE_JUDGE
    while(cin >> N){
        A.assign(N, {});
        for(auto & t :A){
            cin >> t.name;
            for(auto & i : t.score) cin >> i;
        }
        proc();
    }
    return 0;
}

